<!-- UserController.php-->
<?php 
	require 'Admin/Model/NovelModel.php';
	require 'Controller.php';
	class novelController extends Controller{
		function listnovels(){
			$model = new novelModel();
			$data = $model->getnovelList();
			//转向用户列表页面
			include 'Admin/View/novel/novellist.php';
		}

		function novelform(){
			//转向添加用户页面
			include 'Admin/View/novel/novelform.php';
		}

		function noveledit(){
			$id = $_GET['id'];
			$model = new novelModel();
			$result = $model->getUserByID($id);
			include 'Admin/View/novel/noveledit.php';
		}

		function novelsearch(){
			$novelname = $_POST['novelname'];
			$model = new novelModel();
			$data = $model->getnovelinfor($novelname);
			include dirname(dirname(__FILE__)).'/View/novel/search.php';
		}

		function novelupdate(){
			$id = $_GET['id'];
			$model = new novelModel();
			$result = $model->Updatenovel($id);
			if($result){
				echo '修改成功'.'<a href="admin.php?c=novel&m=listnovels">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=novel&m=listnovels = admin.php?c=novel&m=listnovels"); 	
			}else{
				echo '失败';
			}
		}

		function delnovel(){
			$id = $_GET['id'];
			$model = new novelmodel();
			$result = $model->Delnovel($id);
			if($result){
				echo '删除成功'.'<a href="admin.php?c=novel&m=listnovels">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=novel&m=listnovels = admin.php?c=novel&m=listnovels"); 
			}else{
				echo '删除失败';
			}
		}

		function addnovel(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new novelModel();
			$result = $model->addnovel($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="admin.php?c=novel&m=listnovels">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;admin.php?c=novel&m=listnovels = admin.php?c=novel&m=listnovels"); 
			}else{
				echo '失败';
			}

		}
	}
 ?>